import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-08-07
 * Time: 11:25
 */
public class IODemo3 {
    //使用一下字节流来读取文件
    public static void main(String[] args) throws IOException {

        InputStream inputStream = new FileInputStream("d:/test.txt");

//        //进行读操作
//        while (true) {
//            int b = inputStream.read();
//            if (b == -1) {
//                //读取完毕
//                break;
//            }
//            System.out.println("" + (byte)b);
//        }
        while (true) {
            byte[] buffer = new byte[1024];
            int len = inputStream.read(buffer);
            System.out.println("len: " + len);
            if (len == -1) {
                break;
            }
            //此时读取的结果就被放到了 byte 数组中
            for (int i = 0; i < len; i++) {
                System.out.println(""+buffer[i]);
            }
        }
        inputStream.close();
    }
}
